package com.designoutput.elements
{
	import com.designoutput.ui.editors.transformEditorClasses.TransformUtils;
	
	import flash.geom.Matrix;
	import flash.geom.Point;

	public class BaseRectElement extends BaseElement
	{
		override public function getReferencePoints():Vector.<Point> {
			var points:Vector.<Point> = new Vector.<Point>();
			points.push(new Point(0, 0));
			points.push(new Point(width, 0));
			points.push(new Point(0, height));
			
			var m:Matrix = getTransformMatrix();
			
			for(var i:int = 0; i < points.length; i++)
				points[i] = m.transformPoint(points[i]);
			
			return points;
		}
		
		override public function setReferencePoints(points:Vector.<Point>):void {
			var transformationInfo:Object = TransformUtils.get3PointsTransformation(points);
			
			x = transformationInfo.x;
			y = transformationInfo.y;
			width = transformationInfo.width;
			height = transformationInfo.height;
			skewX = transformationInfo.skewX;
			skewY = transformationInfo.skewY;
			scaleX = transformationInfo.scaleX;
			scaleY = transformationInfo.scaleY;
			rotation = transformationInfo.rotation;
			
			updateElement();
		}	
	}
}